﻿@{
    ViewBag.Title = "Reports";
}
@using JustMVCTest.Models
@model JustMVCTest.Models.DropDownList

<html>
<head>
    <title></title>
</head>

<body>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

<script type="text/javascript">
    $(function () {
        $("#Fromdatepicker").datepicker({ dateFormat: 'dd/mm/yy' });
        $("#Todatepicker").datepicker({ dateFormat: 'dd/mm/yy' });
    });
	</script>

<script type="text/javascript">
    function isNumber(o) {
        return !isNaN(o - 0);
    }
 </script>

 <script type="text/javascript">
     function disablegraph() {
         document.getElementById("View Graph").disabled = true;
     }
 </script>

  <script type="text/javascript">
      function enablegraph() {
          document.getElementById("View Graph").disabled = false;
      }
 </script>
 
 <script type="text/javascript">
  function isValidDate(s) {
                    var bits = s.split('/');
                    var d = new Date(bits[2], bits[1] - 1, bits[0]);
                    return d && (d.getMonth() + 1) == bits[1] && d.getDate() == Number(bits[0]);
   return true;                    
    }
 </script>

<script type="text/javascript">
function checkponum() {
    if ((reportform.ReportType[6].checked) && (reportform.PONumber.value == "" || !(isNumber(reportform.PONumber.value)))) {
        alert('Please Enter A Valid PO Number');
        return false;
    }
    return true;
}
function checkitem() {
    if ((reportform.ReportType[6].checked) && (reportform.POItem.value == "" || !(isNumber(reportform.POItem.value)))) {
        alert('Please Enter A Valid Item Number');
        return false;
    }
    return true;
}

/*function checkrate() {
    if ((reportform.ReportType[7].checked) && (reportform.POPercentage.value == "" || !(isNumber(reportform.POPercentage.value)))) {
        alert('Please Enter A Valid Progress Rate');
        return false;
    } 
    else {
        if ((reportform.ReportType[7].checked) && (reportform.POPercentage.value < 0 || reportform.POPercentage.value > 100)) {
            alert('Progress Rate Must Be Between 0 To 100');
            return false;
        }
    }
    return true;
}*/

function checkform() {
    if (!checkponum() || !checkitem()) {
        return false;
    }
    if ((reportform.ReportType[5].checked) && (!isValidDate(document.reportform.FromTopDelaying.value) || !isValidDate(document.reportform.ToTopDelaying.value))) {
        alert('Please Enter A Valid Date');
        return false;
    }
    if ((reportform.ReportType[7].checked) && (!isValidDate(document.reportform.FromCCAmtHis.value) || !isValidDate(document.reportform.ToCCAmtHis.value))) {
        alert('Please Enter A Valid Date');
        return false;
    }
    if ((reportform.ReportType[8].checked) && (!isValidDate(document.reportform.FromIOAmtHis.value) || !isValidDate(document.reportform.ToIOAmtHis.value))) {
        alert('Please Enter A Valid Date');
        return false;
    }
    if ((reportform.ReportType[10].checked) && (document.reportform.CC_Mul_Amt_Listbox.value=="")){
      alert('Please Select A Cost Center');
      return false;
    }
  if ((reportform.ReportType[11].checked) && (document.reportform.IO_Mul_Amt_Listbox.value == "")) {
      alert('Please Select An Internal Order');
      return false;
  }
  if ((reportform.ReportType[12].checked) && (document.reportform.CC_Mul_DD_Listbox.value == "")) {
      alert('Please Select A Cost Center');
      return false;
  }
  if ((reportform.ReportType[13].checked) && (document.reportform.IO_Mul_DD_Listbox.value == "")) {
      alert('Please Select An Internal Order');
      return false;
  }


    return true;
}
 </script>

 <style>
    .FontSize { font-size:medium }
</style>      
       
 <fieldset>
        <legend>Reports</legend>
<br/><br/>
<style type="text/css"> 
td.container > div { width: 100%; height: 100%; overflow:hidden; }
td.container { height: 20px; }
</style>

 @Html.ValidationSummary()
<form name="reportform" method="link" target="_blank" action="@Url.Action("PrintPOs", new { target = "_blank" })">

<table align="center">
    <tr>
        <th style=" color:0066CC;border-color:transparent">
          
        </th>
        <th  style=" color:0066CC;border-color:transparent">
           Report Type
        </th>
        <th  style=" color:0066CC;border-color:transparent">
            Input
        </th>
        <th style=" color:0066CC;border-color:transparent">
          
        </th>
        <th style="border-color:transparent ">

        </th>
    

    </tr>

    <tr style="border-color:transparent;">
        <td rowspan="4" style="border-color:transparent ">
            <input value="Sum" type="radio" name="ReportType" checked=checked onclick="enablegraph()"/>
             
        </td>
        <td rowspan="4" style="border-color:transparent ">
           All Open Items <br /> Summarization:
        </td>
        <td style="border-color:transparent ">
                    <input value="sum_user" type="radio" name="Per" checked=checked />
                    Per User
         </td>
     </tr>
     <tr style="border-color:transparent " >

            <td style="border-color:transparent ">
                    <input value="sum_cc" type="radio" name="Per" />
                    Per Cost Center
            </td>
         </tr>
         <tr style="border-color:transparent ">
            <td style="border-color:transparent ">
                    <input value="sum_io" type="radio" name="Per" />
                    Per Internal Order
            </td>
          </tr>
       <tr style="border-color:transparent ">
            <td style="border-color:transparent ">
                    <input value="sum_vn" type="radio" name="Per" />
                    Per Vendor
            </td>
          </tr>
      <tr style="border-color:transparent ">
        <td style="border-color:transparent ">
            <input value="user" type="radio" name="ReportType" onclick="disablegraph()"/>
        </td>
        <td style="border-color:transparent ">
           User PO's
        </td>
        <td style="border-color:transparent ">
             @Html.DropDownList("Req_List", Model.Req_Type, new { @class = "FontSize" })
        </td>
    </tr>

 <tr style="border-color:transparent ">
        <td style="border-color:transparent ">
            <input value="cc" type="radio" name="ReportType" onclick="disablegraph()"/>
             
        </td>
        <td style="border-color:transparent ">
           Cost Center PO's
        </td>
        <td style="border-color:transparent ">
             @Html.DropDownList("CC_List", Model.CC_Type, new { @class = "FontSize" })
        </td>
    </tr>

     <tr style="border-color:transparent ">
        <td style="border-color:transparent ">
            <input value="io" type="radio" name="ReportType" onclick="disablegraph()"/>
             
        </td>
        <td style="border-color:transparent ">
           Internal Order PO's
        </td>
        <td style="border-color:transparent ">
             @Html.DropDownList("IO_List", Model.IO_Type, new { @class = "FontSize" })
              <!--@Html.ListBox("IO_List", Model.IO_Type, new { @class = "FontSize" }) !-->
        </td>
    </tr>

     <tr  style="border-color:transparent ">
        <td  style="border-color:transparent ">
            <input value="vendor" type="radio" name="ReportType" onclick="disablegraph()" />
             
        </td>
        <td  style="border-color:transparent ">
           All Vendor's PO's &nbsp&nbsp&nbsp&nbsp&nbsp 
        </td>
        <td style="border-color:transparent ">
         @Html.DropDownList("VN_List", Model.VN_Type, new { @class = "FontSize" })
          </td>
    </tr>
    <tr style="border-color:transparent ">
        <td  style="border-color:transparent ">
            <input value="delay" type="radio" name="ReportType" onclick="enablegraph()"/>
        </td>
        <td  style="border-color:transparent ">
           Top "Delaying" Workers
        </td>
        <td  style="border-color:transparent ">
            From: @(Html.Telerik().DatePicker() .Name("FromTopDelaying") )  @Html.ValidationMessage("FromTopDelaying", "*")
            &nbsp&nbsp To:  @(Html.Telerik().DatePicker().Name("ToTopDelaying"))  @Html.ValidationMessage("ToTopDelaying", "*")  &nbsp&nbsp &nbsp&nbsp
        </td>
    </tr>
     <tr style="border-color:transparent ">
        <td style="border-color:transparent ">
            <input value="history" type="radio" name="ReportType"  onclick="disablegraph()"/>
        </td>
        <td style="border-color:transparent ">
           History Of PO
        </td>
        <td style="border-color:transparent ">
            <table align="left">
                <tr style="border-color:transparent ">
                    <td style="border-color:transparent ">
                        PO Number: 
                        <td style="border-color:transparent ">
                            <input type="text" name="PONumber">
                            <!-- @Html.TextBox("PONumber") 
                            @Html.ValidationMessage("PONumber", "*") !-->
                        </td>
                    </td>
                </tr>
             <tr style="border-color:transparent "> 
                <td style="border-color:transparent ">
                     Item: 
                     <td style="border-color:transparent ">
                         <input type="text" name="POItem">
                         <!--Item:  @Html.TextBox("POItem")   !--> 
                     </td> 
                </td> 
             </tr>
            </table>
        </td>
      </tr>
     
  <!--  <tr style="border-color:transparent ">
        <td style="border-color:transparent ">
            <input value="rate" type="radio" name="ReportType" />
             
        </td>
        <td style="border-color:transparent ">
           ALL Open PO's With Less <br /> Or Equal Progress Rate
        </td>   
        <td style="border-color:transparent ">
             <table align="left">
                    <tr style="border-color:transparent ">
                        <td style="border-color:transparent ">
                            Progress Rate: 
                            <td style="border-color:transparent ">
                                <input type="text" name="POPercentage">
                            </td>
                        </td>
                    </tr>
            </table>
        </td>
    </tr> !-->

    <tr style="border-color:transparent ">
        <td style="border-color:transparent ">
            <input value="cc_amt_his" type="radio" name="ReportType"  onclick="enablegraph()" />
             
        </td>
        <td style="border-color:transparent ">
           History Of Open Amount Left By Cost Center<br />
        </td>
        <td style="border-color:transparent ">
             @Html.DropDownList("CC_AMT_His_List",Model.CC_Type, new { @class = "FontSize" })
        </td>
    </tr>
    <tr style="border-color:transparent "> 
         <td style="border-color:transparent ">
         </td>
          <td style="border-color:transparent ">
         </td>
         <td>
            From: @(Html.Telerik().DatePicker() .Name("FromCCAmtHis") )  @Html.ValidationMessage("FromCCAmtHis", "*")
            &nbsp&nbsp To:  @(Html.Telerik().DatePicker().Name("ToCCAmtHis"))  @Html.ValidationMessage("ToCCAmtHis", "*")  &nbsp&nbsp &nbsp&nbsp
         </td>
    </tr>
      
    
    </tr>

    <tr style="border-color:transparent ">
        <td style="border-color:transparent ">
            <input value="io_amt_his" type="radio" name="ReportType" onclick="enablegraph()"/>
             
        </td>
        <td style="border-color:transparent ">
           History Of Open Amount Left By Internal Order<br />
        </td>
        <td style="border-color:transparent ">
             @Html.DropDownList("IO_AMT_His_List",Model.IO_Type, new { @class = "FontSize" })
        </td>
    </tr>
    <tr style="border-color:transparent "> 
         <td style="border-color:transparent ">
         </td>
          <td style="border-color:transparent ">
         </td>
         <td>
            From: @(Html.Telerik().DatePicker() .Name("FromIOAmtHis") )  @Html.ValidationMessage("FromIOAmtHis", "*")
            &nbsp&nbsp To:  @(Html.Telerik().DatePicker().Name("ToIOAmtHis"))  @Html.ValidationMessage("ToIOAmtHis", "*")  &nbsp&nbsp &nbsp&nbsp
         </td>
    </tr>
    
    
    <tr style="border-color:transparent ">
        <td style="border-color:transparent ">
            <input value="cc_amt" type="radio" name="ReportType"  onclick="enablegraph()" />
             
        </td>
        <td style="border-color:transparent ">
           Open Amount Left Of All Internal Orders<br />
           By Cost Center
        </td>
        <td style="border-color:transparent ">
             @Html.DropDownList("CC_AMT_List",Model.CC_Type, new { @class = "FontSize" })
        </td>
    </tr>

    <tr style="border-color:transparent ">
        <td style="border-color:transparent ">
            <input value="mul_cc_amt" type="radio" name="ReportType" onclick="enablegraph()"/>
             
        </td>
        <td style="border-color:transparent ">
           Open Amount Left Of Multiple<br />
           Cost Centers
        </td>
        <td style="border-color:transparent ">
         @Html.ListBox("CC_Mul_Amt_Listbox", Model.CC_Type, new { @class = "FontSize" })
         <!--  @{ foreach (var cc in Model.CC_Type)
              {  
               @Html.CheckBox("CC_Mul_List", cc.Selected, new { @class = "FontSize", id = cc.Text, value = cc.Text })
               @Html.Label(cc.Value,cc.Value)
               <br />
              }
            } !-->
        </td> 
    </tr>

    <tr style="border-color:transparent ">
        <td style="border-color:transparent ">
            <input value="mul_io_amt" type="radio" name="ReportType" onclick="enablegraph()"/>
             
        </td>
        <td style="border-color:transparent ">
           Open Amount Left Of Multiple<br />
           Internal Orders
        </td>
        <td style="border-color:transparent ">
          @Html.ListBox("IO_Mul_Amt_Listbox", Model.IO_Type, new { @class = "FontSize" })
          
        <!--   @{ foreach (var io in Model.IO_Type)
              {  
               @Html.CheckBox("IO_Mul_List", io.Selected, new { @class = "FontSize", id = io.Text, value = io.Text })
               @Html.Label(io.Value,io.Value)
               <br />
              }
            } !-->
        </td>
    </tr>


    <tr style="border-color:transparent ">
        <td style="border-color:transparent ">
            <input value="mul_cc_dd" type="radio" name="ReportType" onclick="enablegraph()" />
             
        </td>
        <td style="border-color:transparent ">
           Number Of POes Expired By Multiple<br />
           Cost Centers
        </td>
        <td style="border-color:transparent ">
         @Html.ListBox("CC_Mul_DD_Listbox", Model.CC_Type, new { @class = "FontSize" })
         <!--  @{ foreach (var cc in Model.CC_Type)
              {  
               @Html.CheckBox("CC_Mul_List", cc.Selected, new { @class = "FontSize", id = cc.Text, value = cc.Text })
               @Html.Label(cc.Value,cc.Value)
               <br />
              }
            } !-->
        </td> 
    </tr>

    <tr style="border-color:transparent ">
        <td style="border-color:transparent ">
            <input value="mul_io_dd" type="radio" name="ReportType" onclick="enablegraph()" />
             
        </td>
        <td style="border-color:transparent ">
           Number Of POes Expired By Multiple<br />
           Internal Orders
        </td>
        <td style="border-color:transparent ">
         @Html.ListBox("IO_Mul_DD_Listbox", Model.IO_Type, new { @class = "FontSize" })
         <!--  @{ foreach (var io in Model.IO_Type)
              {  
               @Html.CheckBox("IO_Mul_List", io.Selected, new { @class = "FontSize", id = io.Text, value = io.Text })
               @Html.Label(io.Value,io.Value)
               <br />
              }
            } !-->
        </td> 
    </tr>


    <tr align="center" style="border-color:transparent ">
        <td style="border-color:transparent; text-align:center ">
    </td>

    <tr align="center" style="border-color:transparent ">
        <td style="border-color:transparent; text-align:center ">

          <!--   @Ajax.ActionLink("NewReport", "PrintPOs", new { onclick = "return checkform()", @class = "roundedButton", target = "_blank" }, new AjaxOptions { HttpMethod = "link" }) !-->
            <font color="gray" size="1">  <input type="submit" value="View Report" name="SubmitButton" id="View Report" onclick = "return checkform()" /> </font>
        </td>
         <td style="border-color:transparent; text-align:center ">
            <font color="gray" size="1">  <input type="submit" value="View Graph" name="SubmitButton" id="View Graph" onclick = "return checkform()" /> </font>
         </td>
    </tr>
</table>

    

  </form>
   </fieldset>
</body>